<script type="text/javascript" >
$(document).ready(function(){
	$("#tgl_awal").datepicker({
		dateFormat: 'yy-mm-dd'
	});
	$("#tgl_akhir").datepicker({
		dateFormat: 'yy-mm-dd'
	});
});
function popupCari(xurl) {
   // document.getElementById('temp').value=temp;
    b=xurl;
    //showPopup(b,'Employee List',500, 500);
	var win = window.open( xurl, "Pilih Diagnosis","status = 1, height = 300, width = 600, resizable = 0, scrollbars=1" );
    if (!win.opener) win.opener = window.self;
}

function cari_keterangan(id_klaim){
	popupCari('module/mod_klaim/js/popup_keterangan.php?id_klaim='+id_klaim);
}
</script>
<div id="tiga_ba">
	<div id="tiga_baa">Verifikasi BPJS</div>
	<div id="tiga_bab">
		<a href="javascript:void(0)" onClick="location.href='utama.php?module=mod_klaim_ina&view=form_tambah'">
			<button class="button">Tambah</button>
		</a>
	</div>
	<div class="clear"></div>
</div>
<?php
require_once 'config/fungsi_laporan.php';
	/*
	$tgl_awal=$_POST['tgl_awal'];
	$tgl_akhir=$_POST['tgl_akhir'];
	$nama_ppk=$_POST['nama_ppk'];	
	$jenis_klaim=$_POST['jenis_klaim'];
	*/
	
	//print_r($_SESSION);
	if(!isset($_SESSION['set_awal'])){
		//echo 'belum diset';
		//echo "<script type='text/javacript'>alert('Silakan Data Diset Dulu');</script>";
		echo "<script>alert('Silakan Data Diset Dulu');</script>";
		echo "<script>window.location.href = 'utama.php?module=mod_verifikasi_awal'</script>";
	}else{
		$tgl_awal=$_SESSION['tgl_awal'];
		$tgl_akhir=$_SESSION['tgl_akhir'];
		$nama_ppk=$_SESSION['nama_ppk'];	
		$jenis_klaim=$_SESSION['jenis_klaim'];
		$jml=$_SESSION['jml'];
	}
	
	
?>
<?php
$level_pengguna = $_SESSION['id_jenis_pengguna'];
?>
<form method=post action='utama.php?module=mod_verifikasi_jamkesmas'>
	<table style="margin-left: 5px;" width="780" >
		<tr>
			<td width="65">Tgl Awal  : </td>
			<td width="200"><?php echo $tgl_awal; ?></td>
			<td width="65">PPK  : </td>
			<td width="200"><?php echo get_nama_ppk($nama_ppk)?></td>
		</tr>
		<tr>
			<td width="65">Tgl Akhir  : </td>
			<td width="200"><?php echo $tgl_akhir; ?></td>
			<td width="65">Jenis : </td>
			<td width="200"><?php 
			$arr_jenis=array('service'=>'Fee For Service','inacbg'=>'Ina CBG');
			echo $arr_jenis[$jenis_klaim];?></td>
			
		</tr>
	</table>
</form>

<table class="tabel">
	<tr>
		<th>NO</th>
		<th>Detail</th>
		<th>Status</th>
		<th>Tgl Masuk</th>
		<th>Tgl Keluar</th>
		<th>LOS</th>
		<th>No RM</th>
		<th>Nama</th>
		<th>Umur</th>
	</tr>
	<?php
		$p= new paging ;
		$batas= 10;
		
		//cek halaman dan posisi halaman
		$posisi = $p ->cariposisi($batas) ;
		//filter verifikator
		if($level_pengguna=='5'){
			//echo 'masuk sini verifikatorku ';
			$filter_verifikator=" and id_verifikator='".$_SESSION['id_pengguna']."'";
		}else{
			$filter_verifikator="";
		}
		$sql="select a.*,pn.nama as nama_penduduk,jp.jenis_peserta,jl.jenis_layanan,
		pk.nama as nama_ppk,ifnull(a.id_status,0) as status,jenis_klaim,
		datediff(a.tgl_keluar,a.tgl_masuk) as selisih
		from klaim a inner join  peserta p on a.id_peserta = p.id_peserta 
		inner join penduduk pn on p.id_penduduk = pn.id_penduduk 
		inner join jenis_peserta jp on p.id_jenis_peserta=jp.id_jenis_peserta
		inner join jenis_layanan jl on a.id_jenis_layanan=jl.id_jenis_layanan
		inner join ppk pk on a.id_ppk=pk.id_ppk
		where  a.tgl_trans between '$tgl_awal' and '$tgl_akhir'
		and a.id_ppk='$nama_ppk' and pn.bpjs='Y' and a.id_status in('1','3') and a.jenis_klaim='$jenis_klaim' $filter_verifikator";
		#echo $sql;
		$qry=mysql_query($sql);
		$no=$posisi + 1;
		if(mysql_num_rows($qry)>0){
		
			while($hasil=mysql_fetch_array($qry)){
			if($hasil['jenis_klaim']=="service"){
				$url="mod_klaim";
			}else{
				$url="mod_klaim_ina";
			}
			
			//ubah status
			if($hasil['status'] < 3){
				$status_baru=0;
			}else if($hasil['status'] == 4){
				$status_baru=4;
			}else{
				$status_baru=3;
			}
	?>
	<form method=post action='utama.php?module=mod_verifikasi_jamkesmas&act=simpan_status'>
	<tr>
		<td align="center" width="30"><?php echo $no; ?></td>
		<td ><a target="_blank" href="module/<?php echo $url?>/form_detail.php?id=<?php echo $hasil['id_klaim']?>"><img src="asset/images/detail.png"></a>
		<a href="javascript:void(0)" title="Tambah" onclick="cari_keterangan('<?php echo $hasil['id_klaim']; ?>')"><img src="asset/images/ritl.png" alt="Tambah" border=0 /></a>
		</td>
		<td align="center" width="60">
			<input type="hidden" name="id_klaim[]" value="<?php echo $hasil['id_klaim'];?>" />
			<?php
				$arr_status=array('0'=>'Pending','3'=>'Diterima','4'=>'Ditolak');
				kombo_from_array("status_verifikasi[]","",$arr_status,$status_baru);
			?>
		</td>
		<td ><?php echo tgl_indonesia($hasil['tgl_masuk']);?></td>
		<td ><?php echo tgl_indonesia($hasil['tgl_keluar']);?></td>
		<td ><?php echo $hasil['selisih'];?></td>
		<td ><?php echo $hasil['no_rm'];?></td>
		<td ><?php echo $hasil['nama_penduduk'];?></td>
		<td ><?php echo konversi_hari($hasil['umur']);?></td>
	</tr>
	
	<?php
				$no++;
			}
	?>
	<tr>
		<td colspan="9" align="left"><input name="submit" type="submit" class="button" value="Simpan Verifikasi" /></td>
	</tr>
	<?php
		}else{
		?>
	
	<tr>
		<td colspan="9" align="center">Data tidak Ada </td>
	</tr>
	<?php
		}
	?>
	
	</form>
</table>
